<template>
 <a-card>
     <a-form layout="horizontal" :form="form" >
        <div :class="advanced ? null: 'fold'">
          <a-row >
            <a-col :md="8" :sm="24" >
                <a-form-item
                label="关键词搜索"
                :labelCol="{span: 5}"
                :wrapperCol="{span: 18, offset: 1}"
                >
                 <a-input-search placeholder="请输入广告计划ID或关键词搜索" enter-button="搜索"  @search="onSearch" />
                </a-form-item>
            </a-col>
          </a-row>
        </div>
     </a-form>
  <a-table :columns="columns" :rowKey="id" :customRow="onClickRow" :data-source="dataSource">
    <a slot="name" slot-scope="text">{{ text }}</a>
  </a-table>

 </a-card>
</template>
<script>
import {ADURL} from '@/services/api'
import {ajaxparems} from '@/services/ajaxrequest'
const columns = [
  {
    title: '广告组-广告计划',
    dataIndex: 'name',
    scopedSlots: { customRender: 'name' },
  },
];

const dataSource = [];

var adverlist = [];
const rowSelection = {
  onChange: (selectedRowKeys, selectedRows) => {
    console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
  },
  onSelect: (record, selected, selectedRows) => {
    console.log(record, selected, selectedRows);
  },
  onSelectAll: (selected, selectedRows, changeRows) => {
    console.log(selected, selectedRows, changeRows);
  },
};
var sondatalist = [];
var data = [];
export default {
    created(){
		this.listNew();
	},
  data() {
    return {
        adverlist,
      dataSource,
      columns,
      rowSelection,
      sondatalist,
      data
    };
  },
   methods: {
    onClickRow(record) {
        return {
            on: {
                click: () => {
                  console.log(record);
                    // let keys = [];
                    // keys.push(record.id); 
                    // this.selectedRowKeys = keys;
                    // console.log(record);
                    this.$router.push({
                        path: '/promotion/advering/addorigin/',
                        query: {
                            ad_id: record.id,//计划ID
                            campaign_id:record.campaign_id,//广告组
                        }
                    })
                }
            }
        }
    },

       listNew(){
            //获取广告组
            // ajaxrequest("1657869217074189", ADVER,"").then((res) => {
            //     var result=res.data;
            //     adverlist =result.data.list;
            //     adverlist.forEach((item,index)=>{
            //         var sonparems = {"filtering":{"campaign_id":item.id}};
                    //获取广告计划
                    ajaxparems(ADURL,"").then((res) => {
                        var sonresult=res.data;
                        sondatalist = sonresult.data.list;
                        // adverlist[index]["children"] = sondatalist;
                        // adverlist[index]['']
                        this.dataSource = sondatalist;
                    })
                // });
                // this.dataSource = adverlist;
                // console.log(this.dataSource);
            // })
       }
   }
};
</script>
